package com.bite.ioc.controller;

import jakarta.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/prop")
@RestController
public class PropertiesController {
    @Value("${my.key}")
    private String myKey;

    @Value("${my.key2}")
    private Integer myKey2;

    @Value("${my.key3}")
    private Boolean myKey3;

    @RequestMapping("/readValue")
    public String readValue(){
        return "从配置文件中读取配置信息:"+ myKey;
    }

    @PostConstruct
    public void readValue2(){
        System.out.println(("从配置文件中读取配置信息:" + myKey));
        System.out.println(("从配置文件中读取配置信息:" + myKey2));
        System.out.println(("从配置文件中读取配置信息:" + myKey3));
    }
}
